$(function() {
    //Define the constructor (Object or class)
    function Character(name, cClass, skillPoints, actionskill, skilltrees){
        this.name = name;                               // string
        this.class = cClass;                            // string
        this.skillPoints = skillPoints;                 // integer
        this.actionskill = actionskill;
        this.skilltrees = skilltrees;
    }

    function ActionSkill(description, name,  duration, cooldown, actionEffects){
        this.description = description;                 // string
        this.name = name;                               // string
        this.actionEffects = actionEffects;
        this.duration = duration;                       // float
        this.cooldown = cooldown;                       // float
    }

    function ActionEffect(stat, value, unit, target , category){
        this.stat = stat;                               // string
        this.value = value;                             // float
        this.unit = unit;                               // string
        this.target = target;                           // string
        this.category = category;                       // string
    }

    function Skilltree(name, pos, maxPoints, currentPoints, skills ){
        this.name = name;                               // string
        this.skills = skills;
        this.pos = pos;                                 // integer
        this.currentPoints = currentPoints;             // integer
        this.maxPoints = maxPoints;                     // integer
    }

    function Skill(effects, description, condition, duration, tier, pos, levels, currentLevel, weightingPerLevel){
        this.effects = effects;
        this.description = description;                 // string
        this.condition = condition;                     // string
        this.duration = duration;                       // float
        this.tier = tier;                               // integer
        this.pos = pos;                                 // integer
        this.levels = levels;                           // integer
        this.currentLevel = currentLevel;               // integer
        this.weightingPerLevel = weightingPerLevel;     // integer
    }

    function Effect(stat, valueBase, valuePerLevel, valueUnit, target, category, isActionPackage, cooldown, maxStacks, stackName, aoe){
        this.stat = stat;                               // string
        this.valueBase = valueBase;                     // integer
        this.valuePerLevel = valuePerLevel;             // float
        this.valueUnit = valueUnit;                     // string
        this.target = target;                           // string
        this.category = category;                       // string
        this.isActionPackage = isActionPackage;         // boolean
        this.cooldown = cooldown;                       // float
        this.maxStacks = maxStacks;                     // integer
        this.stackName = stackName;                     // string
        this.aoe = aoe;                                 // integer
    }

    /*//Add a method to Effect.prototype
    Effect.prototype.sayMyStatChange = function(){
        console.log('Change Stat:'+this.stat+' by: '+this.value);
    }*/

    //Create associative Array of Object instances
    var characters = {};

    characters['wilhelm'] = new Character(
        'Wilhelm','Enforcer', 50,
        new ActionSkill(
            " Press [LB/L1/F] to summon Wolf and Saint, your trusty combat drones. Wolf will roam and attack enemies, while Saint will stay close to you and replenish your Health. Saint has a protective shield, but Wolf can be damaged by enemies. Press and hold [LB/L1/F] to recall Wolf and Saint and have some of your Cooldown refunded.",
            'Wolf and Saint', '35', '42',
            {
                'Pet Support': new ActionEffect('Pet Support', null, null, null, 'support', false),
                'Health Regeneration': new ActionEffect('Health Regeneration', 2.5, '%', 'player', 'defense_health_regen', false)
            }
        ),
        {
            //Adding First of Three Skilltrees
            'Hunter Killer': new Skilltree(
                'Hunter Killer', 1, 0,
                {
                    //Adding Skills in this Skilltree
                    'Afterburner': new Skill(
                        {
                            'Wolf Air Speed': new Effect('Air Speed', 0, 6, '%', 'wolf', 'utility_movement', false, null, 0, null,0),
                            'Reload Speed': new Effect('Reload Speed', 0, 5, '%', 'player', 'utility_reload', false, null, 0, null,0),
                            'Projectile Speed': new Effect('Projectile Speed', 0, 5, '%', 'player', 'utility_projectile', false, null, 0, null,0)
                        },
                        "Wolf's Air Speed is increased. Additionally, your Reload Speed and Projectile speed is increased.",
                        null, null, 1, 1, 5, 0, 1
                    ),
                    'Fire Support' : new Skill(
                        {
                            'Weapon Damage': new Effect('Weapon Damage', 0, 3 , '%', 'player', 'damage_dealt_weapon', false, null, 0, null,0),
                            'Wolf Damage': new Effect('Wolf Damage', 0, 5 , '%', 'wolf', 'damage_dealt_all', false, null, 0, null,0)
                        },
                        "Increases your Weapon Damage and the damage dealt by Wolf.",
                        null, null, 1, 2, 5, 0, 1
                    )
                }
            ),
            //Adding Second of Three Skilltrees
            'Cyber Commando': new Skilltree(
                'Cyber Commando', 2, 0,
                {
                    //Adding Skills in this Skilltree
                    'Laser Focus': new Skill(
                        {
                            'Laser Damage': new Effect('Laser Damage', 0, 4 , '%', 'player', 'damage_dealt_laser', false, null, 0, null,0),
                            'Laser Magazine Size': new Effect('Laser Magazine Size', 0, 2 , '%', 'player', 'utility_magazine_laser', false, null, 0, null,0)
                        },
                        "Increases Gun Damage and Magazine sizes with all Laser Weapons.",
                        null, null, 2, 1, 5, 0, 1
                    ),
                    'Man and Machine' : new Skill(
                        {
                            'Shield Capacity': new Effect('Shield Capacity', 0, 3 , '%', 'player', 'defense_shield_cap', false, null, 0, null,0),
                            'Maximum Health': new Effect('Maximum Health', 0, 3 , '%', 'player', 'defense_health_max', false, null, 0, null,0),
                            'Wolf Shield Capacity': new Effect('Wolf Shield Capacity', 0, 5 , '%', 'wolf', 'defense_shield_cap', false, null, 0, null,0),
                            'Wolf Maximum Health': new Effect('Wolf Maximum Health', 0, 5 , '%', 'wolf', 'defense_health_max', false, null, 0, null,0)
                        },
                        "Increases Maximum Health and Shield Capacity for you and Wolf.",
                        null, null, 2, 2, 5, 0, 1
                    )
                }
            )
        }
    );
    localStorage.setItem('gameStorage', JSON.stringify(characters));
    //console.log(JSON.stringify(characters));
   // console.log(characters['wilhelm']);
});